//
//  MovieDetailView.m
//  HWSGW
//
//  Created by avachen on 15/11/9.
//  Copyright © 2015年 luxuanrui. All rights reserved.
//

#import "MovieDetailView.h"
#import "Movie.h"
#import "StarView.h"
#import "UIImageView+WebCache.h"

@implementation MovieDetailView
- (void)setMovie:(Movie *)movie
{
    if (_movie != movie) {
        _movie = movie;
        
        [self setNeedsLayout];
        
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    //1、电影图片
    NSString *mediumUrl = [self.movie.images objectForKey:@"medium"];
    [_imgView sd_setImageWithURL:[NSURL URLWithString:mediumUrl]];
    
    //2、电影标题
    _titleLabel.text = [NSString stringWithFormat:@"中文：%@", _movie.title];
    
    //3、原标题
    _engLabel.text = [NSString stringWithFormat:@"英文：%@", _movie.original_title];
    
    //4、年份
    _yearLabel.text = [NSString stringWithFormat:@"年份：%@", _movie.year];
    
    //5、评分
    CGFloat rt = [self.movie.average floatValue];
    _starView.rating = rt;
    
    _ratingLabel.text = [NSString stringWithFormat:@"%.1f", rt];
    
}

@end
